<?php

namespace plugin\ycMassage\app\api\controller;

use plugin\ycMassage\app\BaseController;
use plugin\ycMassage\app\model\MassageMoneyRegister;
use plugin\ycMassage\utils\enum\State;
use support\Request;

class MoneyRegisterController extends BaseController
{
    public function index(Request $request)
    {
        $saas_appid = $request->saas_appid;
        $model = MassageMoneyRegister::where(['saas_appid' => $saas_appid, 'state' => State::YES['value']]);
        $model->whereRaw("(start_time IS NULL OR start_time <= NOW()) AND (end_time IS NULL OR end_time >= NOW())");
        $list = $model->select();
        if ($list->isEmpty()) {
            return $this->fail('暂无数据');
        }
        return $this->successRes($list);
    }
}
